import com.qr.pojo.Books;
import com.qr.pojo.Buy;
import com.qr.pojo.User;
import com.qr.service.BookService;
import com.qr.service.BuyService;
import com.qr.service.UserService;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.awt.print.Book;

/**
 * @author 龚倾茹
 * @date 2021/8/15 - 19:31
 */
public class MyTest2 {
    @Test
    public void test(){
        ApplicationContext context=new ClassPathXmlApplicationContext("applicationContext.xml");
        BookService bookServiceImpl = (BookService) context.getBean("BookServiceImpl");
        for (Books books : bookServiceImpl.queryAllBook()) {
            System.out.println(books);

        }
    }
    @Test
    public void test2() {
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        BuyService buyService = (BuyService) context.getBean("buyServiceImpl");
        Buy buy = new Buy();
        buy.setUsername("2019113208");
        buy.setBookID(8);
        buyService.addBuy(buy);
            System.out.println(buy);
        }
    @Test
    public void tset3(){
        ApplicationContext context=new ClassPathXmlApplicationContext("applicationContext.xml");
        BookService bookService = (BookService) context.getBean("BookServiceImpl");
        Books book= bookService.findBookByName("长安十二时辰");
        System.out.println(book);


    }
    }

